module.exports = {
  updateBag: function (dbclient, val, cb) {
    var sql = 'update user_actor set pid1 = ?,pLevel1=?,pid2=?,pLevel2=?,pid3=?,pLevel4=?,pid4=?,pLevel4=?,sid1=?,sLevel1=?,sid2=?,' +
        'sLevel2=?,sid3=?,sLevel3=?,aid1=?,aidLevel1=?,aid2=?,aidLevel2=?,aid3=?,aidLevel3=? where uid = ? and acotrId =?';
    var items = val.items;
    if (typeof items !== 'string') {
      items = JSON.stringify(items);
    }
    var args = [items, val.id];

    dbclient.query(sql, args, function (err, res) {
      if (err) {
        console.error('write mongodb failed!　' + sql + ' ' + JSON.stringify(val));
      }
      if(!!cb && typeof cb == 'function') {
        cb(!!err);
      }
    });
  }
};
